﻿<cfsilent>
	<cfscript>
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		termId = event.getArg("TermID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		changeType = event.getArg("T");
		
		classId = event.getArg("CLSID");
		
		studentType = event.getArg("ST");
		
		currentTab = event.getArg("TabID", "labProfile");
		
		passArgs = structNew();
		structInsert( passArgs, "T", changeType );
		structInsert( passArgs, "TID", termId );
		structInsert( passArgs, "CLSID", classId );

		if ( len(studentType) ) {
			structInsert( passArgs, "ST", studentType );
		}
		
		sql = "SELECT a.sct_name
				FROM t_stuchange_type a 
				WHERE a.sct_code = :changeType ";
				
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="changeType", value=changeType, cfsqltype = "cf_sql_char");

		rs_operObj = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT b.sbj_name,a.grade,
					   b.level_code,a.cls_name,
					   b.schooling_length  
				FROM t_class a 
					 INNER JOIN t_subject b ON b.sbj_id = a.sbj_id 
				WHERE a.cls_id = :classId ";
				
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="classId", value=classId, cfsqltype = "cf_sql_char");

		rs_class = queryObj.execute( sql=sql ).getResult();
		
		event.setArg("pageTitle", "学生学籍管理 - 学籍异动 - " & rs_operObj.sct_name & "向导");

		/* 民族信息 */
		
		sql = "SELECT a.nation_code, a.nation_codez,
					   a.nation_name 
				FROM t_nation a  
				ORDER BY a.nation_name";
				
		queryObj = new Query( datasource=application.dnsSlave );
		
		rs_nation = queryObj.execute( sql=sql ).getResult();
		/* 行政区划 */
		
		sql = "SELECT a.area_code, a.area_name 
				FROM t_dict_china_area a  
				ORDER BY a.area_code ASC";
				
		queryObj = new Query( datasource=application.dnsSlave );
		
		rs_area = queryObj.execute( sql=sql ).getResult();		
		
		/* 学校信息 */
		
		sql = "SELECT a.sch_name,a.sch_citycode  
				FROM t_school a ";

		queryObj = new Query( datasource=application.dnsSlave );
		
		rs_school = queryObj.execute( sql=sql ).getResult();		
		/* 检查表单的核心数据 */
		formCheck = false;
		
		studentId = event.getArg("StudentID");
		rs_student = queryNew("stu_name");
		if ( len(studentId) ) {
			
			sql = "SELECT a.stu_name,b.cls_name 
					FROM t_student a 
						 INNER JOIN t_class b ON b.cls_id = a.cls_id 
					WHERE a.stu_id = :studentId ";
					
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="studentId", value=studentId, cfsqltype = "cf_sql_varchar");
	
			rs_student = queryObj.execute( sql=sql ).getResult();
			
			if (rs_student.recordCount EQ 0 ) {
				formCheck = true;
			}
			
		}
		
		if ( formCheck ) {
			currentTab = event.getArg("TabID", "labCheckForm");
		}
		
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('studentStatusChange')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">学籍异动</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>学籍异动向导 <cfoutput>#rs_operObj.sct_name#</cfoutput> 
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="findStudent">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labProfile">class="active"</cfif> id="labProfile" tabTarget="Profile">填写学生档案</span>
						<cfif formCheck>
							<span <cfif currentTab eq "labCheckForm">class="active"</cfif> id="labCheckForm" tabTarget="CheckForm">学籍异动信息</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
					
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
								
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
				
				<div id="Profile" class="tabContent">
					
					<div class="noticeBlock">
						<h3>建立 <cfoutput>#rs_class.sbj_name#</cfoutput> 专业 学生档案</h3>
						<p>将该学生编入  <em><cfoutput>#rs_class.grade#</cfoutput></em> 级进行跟班学习, 沿用该专业年级培养方案进行人才培养</p>
						<hr/>
					</div>

					<form id="formCheck" onSubmit="javascript:return processVerfiyForm('formCheck');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('statusChangeWizardCreateProfile', passArgs)#</cfoutput>">
						
						<input type="hidden" name="ClassID" value="<cfoutput>#classId#</cfoutput>" />	
						

						<cfif studentType eq "1">
								<!--- 联合培养 --->
								<input type="hidden" name="FosterCode" value="23" />
							<cfelse>
								<!--- 自筹经费 --->
								<input type="hidden" name="FosterCode" value="21" />	
						</cfif>
						
						<cfif studentType eq "1">
								<!--- 其他本科生 --->
								<input type="hidden" name="StudentTypeCode" value="22" />
								
							<cfelseif studentType eq "2">
								<!--- 一年以上进修与培训 --->
								<input type="hidden" name="StudentTypeCode" value="94" />
							
							<cfelse>
							
								<cfif rs_class.level_code eq "3">
										<!--- 普通本科 --->
										<input type="hidden" name="StudentTypeCode" value="21" />	
									<cfelse>
										<!--- 普通专科 --->
										<input type="hidden" name="StudentTypeCode" value="23" />
								</cfif>
						</cfif>
						
						<cfif studentType eq "">
								<!--- 直接授予 --->
								<input type="hidden" name="AcademicType" value="1" />	
							<cfelse>
								<!--- 其他 --->
								<input type="hidden" name="AcademicType" value="9" />	
						</cfif>
						
						<div class="label">
							<span class="req">*</span><b>学号</b>
							<input name="StudentID" id="StudentID" type="text" class="typeIDCard <cfif rs_student.recordCount GT 0>typeError</cfif>" verification="required" maxlength="20" value="<cfoutput>#event.getArg('StudentID')#</cfoutput>" />
							<cfif rs_student.recordCount GT 0>
								<p class="notice1">该学号已经分配给 <cfoutput>#rs_student.cls_name#</cfoutput> 学生 <cfoutput>#rs_student.stu_name#</cfoutput> 所使用, 请更改.</p>
							</cfif>
						</div>
						
						<div class="label">
							<span class="req">*</span><b>学生姓名</b>
							<input name="StudentName" id="StudentName" type="text" class="typeTextTiny inlinePart" verification="required" maxlength="15" value="<cfoutput>#event.getArg('StudentName')#</cfoutput>" />
							曾用名
							<input name="UsedName" id="UsedName" type="text" class="typeTextTiny inlinePart" maxlength="15" value="<cfoutput>#event.getArg('UsedName')#</cfoutput>" />
						</div>				
						
						<div class="label">
							<b>性别</b>
							<input name="Sex" type="radio" class="typeRadio" value="1" <cfif event.getArg('Sex', '1') eq "1">checked="checked"</cfif> />男
							<input name="Sex" type="radio" class="typeRadio" value="2" <cfif event.getArg('Sex') eq "2">checked="checked"</cfif> />女
						</div>
						
						<div class="label">
							<span class="req">*</span><b>身份证号</b>
							<input name="IDCard" id="IDCard" type="text" class="typeIDCard inlinePart" verification="idcard" maxlength="18" value="<cfoutput>#event.getArg('IDCard')#</cfoutput>" />
							<p class="notice">学生个人证件号码, 该资料会用于统一身份认证后的用户身份确认, 等级考试报名以及和其他业务系统的数据交换</p>
						</div>
						
						<div class="label">
							<span class="req">*</span><b>出生日期</b>
							<input name="Birthday" id="Birthday" type="text" class="typeDate" verification="date" maxlength="10" value="<cfoutput>#event.getArg('Birthday')#</cfoutput>" /><span id="calendarTrigger" class="btnCalendar"></span>
						</div>
						
						<hr/>
						
						<div class="label">
							<b>民族</b>
							<select name="NationCode">
                                <cfloop query="rs_nation" >
									<option <cfif rs_nation.nation_code eq event.getArg('NationCode', '01')>selected="selected"</cfif> value="<cfoutput>#rs_nation.nation_code#</cfoutput>"><cfoutput>#rs_nation.nation_name#</cfoutput> (<cfoutput>#rs_nation.nation_codez#</cfoutput>)</option>
								</cfloop>
							</select>
						</div>

						<div class="label">
							<b>籍贯</b>
							<select name="forProvince" id="forProvince" class="inlinePart"></select>
							<select name="forCity" id="forCity" class="inlinePart"></select>
							<select name="forCounty" id="forCounty" class="inlinePart"></select>
							
							<cfset i = 0 />
							<cfset targetProvince = left( event.getArg("forCounty", rs_school.sch_citycode), 2 ) />
							<cfset targetCity = left( event.getArg("forCounty", rs_school.sch_citycode), 4 ) />
							<cfset targetCounty = event.getArg("forCounty", rs_school.sch_citycode) />
							
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {

									var cityArray = [
										<cfloop query = "rs_area" >
											<cfset i++ />
											<cfset id = rs_area.area_code />
											<cfset pid = "" />
											<cfif right(id, 4) eq "0000">
												<cfset id = left(rs_area.area_code, 2) />
											<cfelseif right(id, 2) eq "00">
												<cfset id = left(rs_area.area_code, 4) />
												<cfset pid = left(rs_area.area_code, 2) />
											<cfelse>
												<cfset pid = left(rs_area.area_code, 4) />
											</cfif>
											['<cfoutput>#id#</cfoutput>','<cfoutput>#rs_area.area_name#</cfoutput>','<cfoutput>#pid#</cfoutput>']<cfif i lt rs_area.recordCount>,</cfif>
										</cfloop>
										];
								
									function inputFlush(inputID, dataArray, parentID, preValue) {
									
										$("#" + inputID).removeOption(/./);
										for (var i = 0; i < dataArray.length; i++) {
											if (dataArray[i][2] == parentID) {
												$("#" + inputID).addOption(dataArray[i][0], dataArray[i][1]);
											}
										}
										
										if (preValue) {
											$("#" + inputID).val(preValue);
										}
										else {
											$("#" + inputID).val($("#" + inputID + " option:first").attr('value'));
										}
										
										
									}
									
									/* Preset value */
									inputFlush("forProvince", cityArray, "", '<cfoutput>#event.getArg("forProvince", targetProvince)#</cfoutput>');
									inputFlush("forCity", cityArray, $("#forProvince").val(), '<cfoutput>#event.getArg("forCity", targetCity)#</cfoutput>');
									inputFlush("forCounty", cityArray, $("#forCity").val(), '<cfoutput>#event.getArg("forCounty", targetCounty)#</cfoutput>');
									
									$("#forProvince").change(function(){
										inputFlush("forCity", cityArray, $(this).val());
										inputFlush("forCounty", cityArray, $("#forCity").val());
									});
									
									$("#forCity").change(function(){
										inputFlush("forCounty", cityArray, $(this).val());
									});
									
									
									
									
								});
								// -->
								//]]>				
							</script>
							
						</div>
						
						<div class="label">
							<b>家庭通讯地址</b>
							<input name="HomeAddress" id="HomeAddress" type="text" class="typeText inlinePart" maxlength="100" value="<cfoutput>#event.getArg('HomeAddress')#</cfoutput>" />
							邮编
							<input name="ZipCode" id="ZipCode" type="text" class="typeCode inlinePart" maxlength="10" value="<cfoutput>#event.getArg('ZipCode')#</cfoutput>" />
						</div>
						
						<hr/>

						<div class="lable">
							<input class="button" type="submit" value="提交" />
						</div>
						
					</form>
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$(document).ready(function() {
							Calendar.setup({
								trigger    : "calendarTrigger",
								inputField : "Birthday",
								animation  : false
								});

						});
						// -->
						//]]>
					</script>
					
				</div>
				
				<cfif formCheck>
					
					<div id="CheckForm" class="tabContent">
						
						<div class="noticeBlock">
							<h3>请确认学籍异动操作信息</h3>
							<hr/>
						</div>
						
						<div class="noticeBlock">
							<h3>新建学生档案</h3>
							<hr/>
						</div>
						
						<table class="UItable withBorder">
							<tr>
								<td>学号</td>
								<td><span class="number"><cfoutput>#event.getArg("StudentID")#</cfoutput></span></td>
								<td>姓名</td>
								<td><cfoutput>#event.getArg("StudentName")#</cfoutput></td>
								<td>专业</td>
								<td><cfoutput>#rs_class.sbj_name#</cfoutput></td>
							</tr>
							<tr>
								<td>行政班</td>
								<td><span class="alert"><cfoutput>#rs_class.cls_name#</cfoutput></span></td>
								<td>年级</td>
								<td><span class="number alert"><cfoutput>#rs_class.grade#</cfoutput></span></td>
								<td>预期毕业年份</td>
								<td><span class="number alert"><cfoutput>#int((rs_class.grade + rs_class.schooling_length))#</cfoutput></span></td>
							</tr>
						</table>
						
						<form id="formSign" onSubmit="javascript:return processVerfiyForm('formSign');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('statusChangeWizardCreateDO')#</cfoutput>">
							
							<input type="hidden" name="TermID" value="<cfoutput>#termId#</cfoutput>" />
							
							<!--- 建档信息 --->
							<input type="hidden" name="StudentID" value="<cfoutput>#studentId#</cfoutput>" />
							<input type="hidden" name="StudentName" value="<cfoutput>#event.getArg('StudentName')#</cfoutput>" />
							<input type="hidden" name="UsedName" value="<cfoutput>#event.getArg('UsedName')#</cfoutput>" />
							<input type="hidden" name="Sex" value="<cfoutput>#event.getArg('Sex')#</cfoutput>" />
							<input type="hidden" name="Birthday" value="<cfoutput>#event.getArg('Birthday')#</cfoutput>" />
							<input type="hidden" name="IDCard" value="<cfoutput>#event.getArg('IDCard')#</cfoutput>" />
							
							<input type="hidden" name="FosterCode" value="<cfoutput>#event.getArg('FosterCode')#</cfoutput>" />
							<input type="hidden" name="StudentTypeCode" value="<cfoutput>#event.getArg('StudentTypeCode')#</cfoutput>" />
							<input type="hidden" name="AcademicType" value="<cfoutput>#event.getArg('AcademicType')#</cfoutput>" />
							<input type="hidden" name="NationCode" value="<cfoutput>#event.getArg('NationCode')#</cfoutput>" />
							<input type="hidden" name="AreaCode" value="<cfoutput>#event.getArg('forCounty')#</cfoutput>" />
							<input type="hidden" name="HomeAddress" value="<cfoutput>#event.getArg('HomeAddress')#</cfoutput>" />
							<input type="hidden" name="ZipCode" value="<cfoutput>#event.getArg('ZipCode')#</cfoutput>" />

							<input type="hidden" name="IDCardType" value="01" />
							<input type="hidden" name="StatusCode" value="01" />
							
							<input type="hidden" name="ClassID" value="<cfoutput>#classId#</cfoutput>" />
							
							<input type="hidden" name="ChangeTypeCode" value="<cfoutput>#changeType#</cfoutput>" />
							
							<input type="hidden" name="Target" value="<cfoutput>#rs_school.sch_name#</cfoutput>" />
							
							<!--- 联合培养标识 --->
							<cfif studentType eq "1">
								<input type="hidden" name="Cooperation" value="1" />
							</cfif>
							
							<!--- 进修生标识 --->
							<cfif studentType eq "2">
								<input type="hidden" name="FurtherStudy" value="1" />
							</cfif>
							
							<hr/>
							
							<cfswitch expression="#changeType#">
								
								<cfcase value="24">
									<!--- 专升本 --->
									<div class="label">
										<b>专科毕业学校</b>
										<input name="Source" id="Source" type="text" class="typeText typeText" verification="required" maxlength="60" value="" />
									</div>
								</cfcase>

								<cfcase value="22">
									<!--- 转学入 --->
									<cfif studentType eq "1">
											
											<!--- 联合培养 --->
											<div class="label">
												<b>联合培养学校</b>
												<input name="Source" id="Source" type="text" class="typeText typeText" verification="required" maxlength="60" value="" />
											</div>

										<cfelseif studentType eq "2">

											<!--- 进修生 --->
											<div class="label">
												<b>进修生单位</b>
												<input name="Source" id="Source" type="text" class="typeText typeText" verification="required" maxlength="60" value="" />
											</div>


										<cfelse>
											
											<!--- 其他学校学生 --->
											<div class="label">
												<b>转出学校</b>
												<input name="Source" id="Source" type="text" class="typeText typeText" verification="required" maxlength="60" value="" />
											</div>
									</cfif>
									
									
								</cfcase>
								
							</cfswitch>
							
							<div class="label">
								<b>审批文号</b>
								<input name="ApproveDocument" id="ApproveDocument" type="text" class="typeText typeTextShort" maxlength="24" value="" />
							</div>
						
							<div class="label">
								<span class="req">*</span><b>审批日期</b>
								<input name="ApproveDate" id="ApproveDate" type="text" class="typeDate" verification="date" maxlength="10" value="<cfoutput>#dateFormat(now(), 'YYYY-MM-DD')#</cfoutput>" /><span id="dateTrigger" class="btnCalendar"></span>
							</div>
						
							<div class="lable">
								<input class="button" type="submit" value="执行异动" />
							</div>
							
						</form>
						
					</div>
					
				</cfif>
				
			</div>
		</li>
	</ul>
</div>



